package com.xohn.ffmpeg1;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.os.Environment;
import android.widget.TextView;

import com.xohn.ffmpeg.AVUtils;

import java.io.File;

public class MainActivity extends AppCompatActivity {
    String ROOT = Environment.getExternalStorageDirectory().getAbsolutePath() + "/xohnffmpeg/";
    // Used to load the 'native-lib' library on application startup.

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // Example of a call to a native method
        TextView tv = findViewById(R.id.sample_text);
        tv.setText(AVUtils.getInstance().stringFromJNI());

        //generateParentFolder();
        //yuv
        //AVUtils.getInstance().yuv420Split(ROOT+"lena_256x256_yuv420p.yuv",256,256,1);
        //AVUtils.getInstance().yuv444Split(ROOT+"lena_256x256_yuv444p.yuv",256,256,1);
        //AVUtils.getInstance().yuv420Gray(ROOT+"lena_256x256_yuv420p.yuv",256,256,1);
        //AVUtils.getInstance().yuv420Halfy(ROOT+"lena_256x256_yuv420p.yuv",256,256,1);
        //AVUtils.getInstance().yuv420Border(ROOT+"lena_256x256_yuv420p.yuv",256,256,20,1);
        //AVUtils.getInstance().yuv420GrayBar(ROOT+"graybar_640x360_yuv420p.yuv",640, 360,0,255,10);
        //AVUtils.getInstance().yuv420Psnr(ROOT+"lena_256x256_yuv420p.yuv",ROOT+"lena_distort_256x256_yuv420p.yuv",256,256,1);

        //rgb
        //AVUtils.getInstance().rgb24Split(ROOT+"cie1931_500x500.rgb",500,500,1);
        //AVUtils.getInstance().rgb24ToBmp(ROOT+"lena_256x256_rgb24.rgb",256,256,ROOT+"lena_256x256.bmp");
        //AVUtils.getInstance().rgb24ToYuv420(ROOT+"lena_256x256_rgb24.rgb",256,256,1,ROOT+"lena_256x256_rgb24ToYuv420.yuv");
        //AVUtils.getInstance().rgb24ColorBar(640, 360,ROOT+"rgb24colorbar_640x360.rgb");

        //pcm
        //AVUtils.getInstance().pcm16leSplit(ROOT+"NocturneNo2inEflat_44.1k_s16le.pcm");
        //AVUtils.getInstance().pcm16leHalfVolLeft(ROOT+"NocturneNo2inEflat_44.1k_s16le.pcm");
        //AVUtils.getInstance().pcm16leDoubleSpeed(ROOT+"NocturneNo2inEflat_44.1k_s16le.pcm");
        //AVUtils.getInstance().pcm16leToPcm8(ROOT+"NocturneNo2inEflat_44.1k_s16le.pcm");
        //AVUtils.getInstance().pcm16leCutSingleChannel(ROOT+"drum.pcm",2360,120);
        //AVUtils.getInstance().pcm16leToWave(ROOT+"NocturneNo2inEflat_44.1k_s16le.pcm",2,44100,ROOT+"output_nocturne.wav");

        //h264
        //AVUtils.getInstance().h264Parser(ROOT+"sintel.h264");

        //aac
        //AVUtils.getInstance().aacParser(ROOT+"nocturne.aac");

        //flv
        //AVUtils.getInstance().flvParser(ROOT+"cuc_ieschool.flv");

        //udp-rtp
        //AVUtils.getInstance().udpRtpParser(ROOT+"output_sintel.ts");
    }

    private void generateParentFolder() {
        File tempFile = new File(ROOT);
        if (!tempFile.exists()) {
            tempFile.mkdirs();
        }
    }
    /**
     * A native method that is implemented by the 'native-lib' native library,
     * which is packaged with this application.
     */
}
